package com.shop.loan.model.view;


import com.shop.loan.model.Channel;
import com.shop.loan.proxy.StatisticsByOrderNumProxy;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.jpa.model.BaseModel;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import java.math.BigDecimal;

@Setter
@Getter
@Entity
@Table(name = "s_order_number_s",
        uniqueConstraints = {
                @UniqueConstraint(columnNames = "number")
        })
@Erupt(
        name = "下单数逾期统计",
        dataProxy = StatisticsByOrderNumProxy.class,
        power = @Power(add = false, edit = false, viewDetails = false, delete = false)
)
public class StatisticsByOrderNum extends BaseModel {

    @Transient
    @EruptField(
            edit = @Edit(
                    title = "是否到期",
                    type = EditType.CHOICE,
                    notNull = true,
                    search = @Search,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "已到期", value = "1"),
                            }
                    ))
    )
    private Boolean isExpire;

    @EruptField(
            views = @View(title = "单数"),
            edit = @Edit(title = "单数",
                    readonly = @Readonly,
                    dateType = @DateType(type = DateType.Type.DATE))
    )
    private Integer number;


    @Transient
    @EruptField(
            edit = @Edit(
                    title = "所属渠道",
                    search = @Search(vague = true),
                    type = EditType.REFERENCE_TREE
            )
    )
    private Channel channel;



    @Transient
    @EruptField(
            views = @View(title = "订单数量"),
            edit = @Edit(
                    title = "订单数量"
            )
    )
    private Integer orderNum;

    @Transient
    @EruptField(
            views = @View(title = "账单金额"),
            edit = @Edit(
                    title = "账单金额"
            )
    )
    private Integer money;


    @Transient
    @EruptField(
            views = @View(title = "已还本息"),
            edit = @Edit(
                    title = "已还本息"
            )
    )
    private Integer payMoney;


    @Transient
    @EruptField(
            views = @View(title = "已还商品金额"),
            edit = @Edit(
                    title = "已还商品金额"
            )
    )
    private Integer payMoneyByGuarantee;

    @Transient
    @EruptField(
            views = @View(title = "优惠本息", width = "120px"),
            edit = @Edit(
                    title = "优惠本息"
            )
    )
    private BigDecimal discountsMoney;


    @Transient
    @EruptField(
            views = @View(title = "优惠商品金额", width = "120px"),
            edit = @Edit(
                    title = "优惠商品金额"
            )
    )
    private BigDecimal discountsMoneyByGoods;

    @Transient
    @EruptField(
            views = @View(title = "逾期金额", width = "120px"),
            edit = @Edit(
                    title = "逾期金额"
            )
    )
    private BigDecimal overdueMoney;

    @Transient
    @EruptField(
            views = @View(title = "回款率(%)", width = "120px"),
            edit = @Edit(
                    title = "回款率"
            )
    )
    private BigDecimal payRate;

    @Transient
    @EruptField(
            views = @View(title = "逾期率(%)", width = "120px"),
            edit = @Edit(
                    title = "逾期率(%)"
            )
    )
    private BigDecimal overdueRate;


    @Transient
    @EruptField(
            views = @View(title = "优惠率(%)", width = "120px"),
            edit = @Edit(
                    title = "优惠率(%)"
            )
    )
    private BigDecimal discountsRate;

}

